package com.example.glidestudy;

import android.net.Uri;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.bumptech.glide.DrawableRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.ViewTarget;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    private ImageView mImgGlide, mImgGlide1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findView();

    }

    private void findView() {
        mImgGlide = (ImageView) findViewById(R.id.img_glide);
        mImgGlide1 = (ImageView) findViewById(R.id.img_glide1);
//        String url = "http://upload.ugc.yanxiu.com/old/thumbnail_12073924_100x100.jpg";
        String picurl = "http://pic18.nipic.com/20111203/2622205_180623209102_2.jpg";
        String vidourl = "http://dlqncdn.miaopai.com/stream/MVaux41A4lkuWloBbGUGaQ__.mp4";
        Environment.getExternalStorageDirectory();
        Glide.with(this).load(picurl).thumbnail(0.1f).placeholder(R.mipmap.ic_launcher).into(mImgGlide);
        //Glide.with(this).load(new File()).asGif().into(mImgGlide1);

        // Glide.with(this).load("").thumbnail().into(mImgGlide);
        Glide.with(this).load("").asBitmap().toBytes().centerCrop().into(new SimpleTarget<byte[]>() {
            @Override
            public void onResourceReady(byte[] resource, GlideAnimation<? super byte[]> glideAnimation) {

            }
        });
       //Z DiskCacheStrategy.RESULT;

//        Glide.with(this).load(url).placeholder(R.mipmap.ic_launcher).crossFade().into(new SimpleTarget<GlideDrawable>() {
//            @Override
//            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
//
//            }
//        });

        FrcView frcView= new FrcView(this);
        Glide.with(this).load("").into(new ViewTarget<FrcView,GlideDrawable>(frcView) {
            @Override
            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {

            }
        });

    }
}
